package org.myorg;

import java.io.*;

public class S2 extends Para2{
	public static void main(String[] args) throws Exception {
		
		System.out.println("enter main\n");

		//reserve results
		String cmd = "mkdir -p ./res";
		RWF.execmd(cmd);
		
		//for running much programmers
		File res = null; 
		String mark = "0";
		res = new File("./res/smark");
		if (res.exists()) {
			BufferedReader input = new BufferedReader(new FileReader(res));			
		    mark = input.readLine();
		    int im = 1;
		    if(mark != null){
		    	im =  Integer.parseInt(mark);
		    }
		    
		    
		    PrintWriter output = new PrintWriter(new FileWriter(res));
		    output.print(im+1);
		    output.close();
		} 
		else {
		    PrintWriter output = new PrintWriter(new FileWriter(res));
		    output.print(1);
		    output.close();
		}

		//put different results of different program to different directory 
		spath = spath + mark;
		cmd = "mkdir -p " + spath;
		RWF.execmd(cmd);

		float low = -100;
		float high = 100;
		
		for (int i = 0; i < ln; i++) {

			long st = System.currentTimeMillis();
			String r = FGA2.ga(geneLength, low, high, spn, p_cross, p_mut, i_num, function,mag);
			long rt = System.currentTimeMillis() - st;
			System.out.println(i + "run time is " + rt);
			
			RWF.wf(r,spath + "/s_r");
			
		}
		
		System.out.println("Game over");

	}
	
}
